home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / devices / src / waitio.c < prev   
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.9 KB  |  88 lines

  1. /*
  2.     (C) 1995, 96 AROS - The Amiga Replacement OS
  3.     $Id$
  4.     $Log$
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "exec_intern.h"
  9. #include <exec/io.h>
  10. #include <aros/libcall.h>
  11.  
  12. /*****************************************************************************
  13.  
  14.     NAME */
  15.     #include <clib/exec_protos.h>
  16.  
  17.     __AROS_LH1(BYTE, WaitIO,
  18.  
  19. /*  SYNOPSIS */
  20.     __AROS_LA(struct IORequest *, iORequest, A1),
  21.  
  22. /*  LOCATION */
  23.     struct ExecBase *, SysBase, 79, Exec)
  24.  
  25. /*  FUNCTION
  26.     Waits until the I/O request is completed and removes it from the
  27.     reply port. If the message is already done when calling this function
  28.     it doesn't wait but just remove the message.
  29.  
  30.     INPUTS
  31.     iORequest - Pointer to iorequest structure.
  32.  
  33.     RESULT
  34.     Error state of I/O request.
  35.  
  36.     NOTES
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     OpenDevice(), CloseDevice(), DoIO(), SendIO(), AbortIO(), CheckIO()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.  
  49. ******************************************************************************/
  50. {
  51.     __AROS_FUNC_INIT
  52.  
  53.     /*
  54.     The I/O request is still in use if it wasn't done quick
  55.     and isn't yet replied (ln_Type==NT_MESSAGE).
  56.     If it is still in use wait until it is complete.
  57.     Note the the port may be used for other things as well - so
  58.     don't just wait but repeat the check.
  59.     */
  60.     while(!(iORequest->io_Flags&IOF_QUICK)&&
  61.       iORequest->io_Message.mn_Node.ln_Type==NT_MESSAGE)
  62.     /*
  63.         Wait at the reply port. Don't use WaitPort() - there may
  64.         already be other messages waiting at it.
  65.     */
  66.     Wait(1<<iORequest->io_Message.mn_ReplyPort->mp_SigBit);
  67.  
  68.     /*
  69.     If ln_Type is NT_REPLYMSG the I/O request must be removed from
  70.     the replyport's waiting queue.
  71.     */
  72.     if(iORequest->io_Message.mn_Node.ln_Type==NT_REPLYMSG)
  73.     {
  74.     /* Arbitrate for the message queue. */
  75.     Disable();
  76.  
  77.     /* Remove the message */
  78.     Remove(&iORequest->io_Message.mn_Node);
  79.     Enable();
  80.     }
  81.  
  82.     /* All done. Get returncode. */
  83.     return iORequest->io_Error;
  84.  
  85.     __AROS_FUNC_EXIT
  86. } /* WaitIO */
  87.  
  88.